package com.example.democonsumer.service;

import com.example.api.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

/**
 * <b><code>OpenFeignService</code></b>
 * <p>
 * Description
 * <p>
 * <b>Create Time:</b> 2021/9/24 11:06.
 *
 * @author qd.yt
 * @version 0.0.1
 * @since demo-openfeign v0.0.1
 */
@FeignClient(name = "demo-provider",path = "/openfeign")
@RestController
public interface OpenFeignService {
    @GetMapping("/provider/{id}")
    String get(@PathVariable("id")Integer id);

    /**
     * 参数默认是@RequestBody标注的，如果通过POJO表单传参的，使用@SpringQueryMap标注
     */
    @PostMapping("/provider/order1")
    Order createOrder1(@SpringQueryMap Order order);

    /**
     * 参数默认是@RequestBody标注的，这里的@RequestBody可以不填
     * 方法名称任意
     */
    @PostMapping("/provider/order2")
    Order createOrder2(@RequestBody Order order);

    /**
     * 必须要@RequestParam注解标注，且value属性必须填上参数名
     * 方法参数名可以任意，但是@RequestParam注解中的value属性必须和provider中的参数名相同
     */
    @PostMapping("/openfeign/provider/test2")
    String test(@RequestParam("id") String arg1, @RequestParam("name") String arg2);
}
